#include "example.h"
#include "configset.h"

Example::Example()
{

}

QString     Example::GetLable(void)  //获取库标签
{
    return "测试插件";
}

void        Example::showdetail(void)//显示细节
{

}

QJsonObject Example::Config(QJsonObject qjson)    //配置
{
    QJsonObject TMEP;

    ConfigWid *pConfig = new ConfigWid(qjson);
    pConfig->show();

    QEventLoop loop;
    connect(pConfig, SIGNAL(finished(int)), &loop, SLOT(quit()));

    loop.exec(); // 进入事件循环，等待对话框关闭
    qDebug()<<"result:"<< pConfig->result();
    if(pConfig->result())
        TMEP = pConfig->getConfig();
    delete pConfig;
    return TMEP;
}

QJsonObject Example:: StartRun(QJsonObject qjson) //开始执行
{
    QJsonObject qJsonRes;
    QString strretvalue = 0;
    if(qjson["cmd"] == "buildCpuArchitecture")
    {
        strretvalue = QSysInfo::buildCpuArchitecture();
    }
    else if(qjson["cmd"] ==  "currentCpuArchitecture")
    {
        strretvalue = QSysInfo::currentCpuArchitecture();
    }
    else if(qjson["cmd"] == "buildAbi")
    {
        strretvalue = QSysInfo::buildAbi();
    }
    else if(qjson["cmd"] == "kernelType")
    {
        strretvalue =QSysInfo::kernelType();
    }
    else if(qjson["cmd"] == "kernelVersion" )
    {
        strretvalue =QSysInfo::kernelVersion();
    }
    else if(qjson["cmd"] == "productType" )
    {
        strretvalue =QSysInfo::productType();
    }
    else if(qjson["cmd"] == "productVersion" )
    {
        strretvalue =QSysInfo::productVersion();
    }
    else if(qjson["cmd"] == "prettyProductName" )
    {
        strretvalue =QSysInfo::prettyProductName();
    }
    else if(qjson["cmd"] == "machineHostName" )
    {
        strretvalue =QSysInfo::machineHostName();
    }
    qJsonRes.insert("failreason","");
    qJsonRes.insert("runvalue",strretvalue);
    qJsonRes.insert("runvalue_type","str");
    return qJsonRes;
}
